package ml;

public class StarBag {
    private final double [] _x;
    private final double [] _y;
    private final double [] _mass;

    public StarBag(int n, double sizeX, double sizeY){
	_x = new double[n];
	_y = new double[n];
	_mass = new double[n];

	for (int i=0;i<n;i++){
	    _x[i] = sizeX * (Math.random() - 0.5);
	    _y[i] = sizeY * (Math.random() - 0.5);
	    _mass[i] = 1.0;
	    //			System.out.println("Star " + i + ": " + _x[i] + "," + _y[i]);
	}
    }

    public StarBag(double[] xStar, double[] yStar) {
	int n = xStar.length;
	_x = new double[n];
	_y = new double[n];
	_mass = new double[n];

	for (int i=0;i<n;i++){
	    _x[i] = xStar[i];
	    _y[i] = yStar[i];
	    _mass[i] = 1.0;
	    //			System.out.println("Star " + i + ": " + _x[i] + "," + _y[i]);
	}
    }

    public Double[] getPos(int i){
	return new Double[] {_x[i], _y[i], _mass[i]};
    }
    
    public double[] getXArray(){
	return _x;
    }
    public double[] getYArray(){
	return _y;
    }
    public double[] getMassArray(){
	return _mass;
    }

    public int size() {
	return _x.length;
    }

    public double getX(int i) {
	return _x[i];
    }

    public double getY(int i) {
	return _y[i];
    }

    //	public double [] getDeflected(double xRay, double yRay){
    //		double [] result = new double[]{xRay, yRay};
    //		
    //		//First the stars contribution.
    //		for (int i =0;i<_x.length;i++){
    //			double dx = xRay -_x[i];
    //			double dy = yRay -_y[i];
    //			
    //			double sep = dx*dx + dy*dy;
    //			result[0] -= dx/sep;
    //			result[1] -= dy/sep;
    //		}
    //		
    ////		//The distributed mass and the shear
    //		result[0] -= (MicrolensingSimulation.sigmaMatter-MicrolensingSimulation.shear) * xRay;
    //		result[1] -= (MicrolensingSimulation.sigmaMatter+MicrolensingSimulation.shear) * yRay;
    //		
    //		return result;
    //		
    //	}
}
